﻿// (c) Comkarl Calipso
// By Matías Fidemraizer (http://www.matiasfidemraizer.com)
// -------------------------------------------------
// http://calipso.codeplex.com
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using System;

namespace Comkarl.Web
{
    /// <summary>
    /// Represents a ScriptControl client property, which is a server-side proprty that will be
    /// also available in the client-side part.
    /// </summary>
    public sealed class ClientProperty
    {
        private string _name;

        /// <summary>
        /// Gets or sets an unique identifier for this property-
        /// </summary>
        public Guid Id
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or sets the exact name of server-side property.
        /// </summary>
        public string Name
        {
            get
            {
                return _name;
            }
            set
            {
                if(!string.IsNullOrEmpty(value))
                {
                    if(value.Length > 1)
                    {
                        _name = char.ToLowerInvariant(value[0]) + value.Substring(1);
                    }
                    else
                    {
                        _name = value.ToLowerInvariant();
                    }
                }
            }
        }

        /// <summary>
        /// Gets or sets the property value.
        /// </summary>
        public object Value
        {
            get;
            set;
        }

        public override string ToString()
        {
            return string.Format("{0}: {1}", Name, Value);
        }
    }
}